/**
 * Huisou.com Inc.
 * Copyright (c) 2011-2012 All Rights Reserved.
 */

package com.lyqg.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.core.utils.Md5Util;

/**
 * @description
 * 
 * @author chenzehe
 * @email hljuczh@163.com
 * @create 2012-8-14 下午08:14:17
 */
@Entity
@Table(name = "tbl_user")
public class User {
	@Id
	@Column(name = "id")
	@GeneratedValue
	private Integer id;

	@Column(name = "username")
	private String username;

	@Column(name = "password")
	private String password;

	@Column(name = "email")
	private String email;

	@Column(name = "point")
	private Integer point;

	@Column(name = "issue_time")
	private Date issueTime;

	@Column(name = "modify_time")
	private Date modifyTime;

	@Column(name = "status")
	private Integer status;

	@Column(name = "avatar")
	private String avatar;

	@Transient
	private int grade;

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		// MD5加密并倒序
		this.password = new StringBuilder(Md5Util.encode(password)).reverse()
				.toString();
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getIssueTime() {
		return issueTime;
	}

	public void setIssueTime(Date issueTime) {
		this.issueTime = issueTime;
	}

	public Date getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	public Integer getPoint() {
		return point;
	}

	public void setPoint(Integer point) {
		this.point = point;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public int getGrade() {
		this.grade = 0;
		if (point > 1 && point <= 100) {
			this.grade = 1;
		} else if (point > 100 && point <= 240) {
			this.grade = 2;
		} else if (point > 240 && point <= 420) {
			this.grade = 3;
		} else if (point > 420 && point <= 640) {
			this.grade = 4;
		} else if (point > 640 && point <= 900) {
			this.grade = 5;
		} else if (point > 900 && point <= 1200) {
			this.grade = 6;
		} else if (point > 1200 && point <= 1540) {
			this.grade = 7;
		} else if (point > 1540 && point <= 1920) {
			this.grade = 8;
		} else if (point > 1920 && point <= 2340) {
			this.grade = 9;
		} else if (point > 2340 && point <= 2800) {
			this.grade = 10;
		} else if (point > 2800 && point <= 3300) {
			this.grade = 11;
		} else if (point > 3300 && point <= 3840) {
			this.grade = 12;
		} else if (point > 3840 && point <= 4420) {
			this.grade = 13;
		} else if (point > 4420 && point <= 5040) {
			this.grade = 14;
		} else if (point > 5040 && point <= 5700) {
			this.grade = 15;
		} else if (point > 5700 && point <= 6400) {
			this.grade = 16;
		} else if (point > 6400 && point <= 7140) {
			this.grade = 17;
		} else if (point > 7140 && point <= 7920) {
			this.grade = 18;
		} else if (point > 7920 && point <= 8740) {
			this.grade = 19;
		} else if (point > 8740 && point <= 9600) {
			this.grade = 20;
		} else if (point > 9600 && point <= 10500) {
			this.grade = 21;
		} else if (point > 10500 && point <= 11440) {
			this.grade = 22;
		} else if (point > 11440 && point <= 12420) {
			this.grade = 23;
		} else if (point > 12420 && point <= 13440) {
			this.grade = 24;
		} else if (point > 13440 && point <= 14500) {
			this.grade = 25;
		} else if (point > 14500 && point <= 15600) {
			this.grade = 26;
		} else if (point > 15600 && point <= 16740) {
			this.grade = 27;
		} else if (point > 16740 && point <= 17920) {
			this.grade = 28;
		} else if (point > 17920 && point <= 19140) {
			this.grade = 29;
		} else if (point > 19140 && point <= 20400) {
			this.grade = 30;
		} else if (point > 20400 && point <= 21700) {
			this.grade = 31;
		} else if (point > 21700 && point <= 23040) {
			this.grade = 32;
		} else if (point > 23040 && point <= 24420) {
			this.grade = 33;
		} else if (point > 24420 && point <= 25840) {
			this.grade = 34;
		} else if (point > 25840 && point <= 27300) {
			this.grade = 35;
		} else if (point > 27300 && point <= 28800) {
			this.grade = 36;
		} else if (point > 28800 && point <= 30340) {
			this.grade = 37;
		} else if (point > 30340 && point <= 31920) {
			this.grade = 38;
		} else if (point > 31920 && point <= 33540) {
			this.grade = 39;
		} else if (point > 33540 && point <= 35200) {
			this.grade = 40;
		} else if (point > 35200) {
			this.grade = 41;
		}
		return this.grade;
	}
}
